

import 'GoodsDetailsBean.dart';

class AddCartEntity{

  //(value = "商品id")
   String? productId;
  //(value = "商店id")
   String? storeId;

  //(value = "店铺名")
   String? storeName;
  //(value = "skuid")
   int? productSkuId;

  //(value = "购买数量")
   int? quantity;

  //(value = "添加到购物车的价格")
   String? price;

  //(value = "商品主图")
   String? productPic;

  //(value = "商品名称")
   String? productName;

  //(value = "商品副标题（卖点）")
   String? productSubTitle;

  //(value = "商品sku条码")
   String? productSkuCode;

  //(value = "商品分类")
   int? productCategoryId;

  //(value = "品牌名")
   String? productBrand;

   String? productSn;

  //(value = "商品销售属性:[{'key':'颜色','value':'颜色'},{'key':'容量','value':'4G'}]")
   String? productAttr;

  // "商品类型：PROTYPE0003-样品，PROTYPE0001-现货，PROTYPE0002-期货")
   String? productType;

   AddCartEntity(SkuStockList skuStockBean, Product productBean, int quantity, String productType) {
    if (productBean == null || skuStockBean == null) return;
    this.productId = productBean.productId;
    this.storeId = productBean.storeId;
    this.productSkuId = skuStockBean.id;
    this.quantity = quantity;
    // PROTYPE0003 样品  PROTYPE0002 期货  PROTYPE0001 现货
    //根据不同类型传不同价格
    double? s = ("PROTYPE0003"==productType) ? skuStockBean.samplePrice : ("PROTYPE0002"==productType ? skuStockBean.orderPrice: skuStockBean.price);
    this.price = s==null? "0":s.toString();
    this.productPic = productBean.pic;
    this.productName = productBean.name;
    this.productSubTitle = null;
    this.productSkuCode = skuStockBean.skuCode;
    this.productCategoryId = productBean.productCategoryId;
    this.productBrand = null;
    this.productAttr = skuStockBean.spData;
    //商品类型：PROTYPE0003-样品，PROTYPE0001-现货，PROTYPE0002-期货
    this.productType = productType;
  }


   Map<String, dynamic> toJson() {
     final Map<String, dynamic> data = new Map<String, dynamic>();
     data['price'] = this.price;
     data['productAttr'] = this.productAttr;
     data['productCategoryId'] = this.productCategoryId;
     data['productId'] = this.productId;
     data['productName'] = this.productName;
     data['productPic'] = this.productPic;
     data['productSkuCode'] = this.productSkuCode;
     data['productSkuId'] = this.productSkuId;
     data['productType'] = this.productType;
     data['quantity'] = this.quantity;
     data['storeId'] = this.storeId;
     return data;
   }

}